//% color="#4169E1" iconWidth=50 iconHeight=40
namespace DFRobot_VEML6075{

    //% block="Initialize VEML6075 UV sensor wait until successful" blockType="command" 
    
    export function DFRobot_VEML6075Init(parameter: any, block: any) {
       
        

        Generator.addInclude("DFRobot_VEML6075Init", "#include <Wire.h>");
        Generator.addInclude("DFRobot_VEML6075Init1", "#include <DFRobot_VEML6075.h>");
        
        Generator.addObject("DFRobot_VEML6075Init","DFRobot_VEML6075_IIC",`VEML6075(&Wire,0x10);`);
  
        Generator.addSetup(`DFRobot_VEML6075InitReady`, `while(VEML6075.begin() != 0);`);
       
        
    }
     //% block="Read VEML6075 [UV] Strength" blockType="reporter" 
     //% UV.shadow="dropdown"  UV.options="UV"
     export function DFRobot_VEML6075ReadyUV(parameter: any, block: any) { 
        let uv = parameter.UV.code

        Generator.addCode( [`VEML6075.getUv${uv}()`,Generator.ORDER_UNARY_POSTFIX]);
   
   }

    //% block="Read VEML6075 UV Index" blockType="reporter"  
    export function DFRobot_VEML6075Ready(parameter: any, block: any) { 
        Generator.addCode( [`VEML6075.getUvi(VEML6075.getUva(),VEML6075.getUvb())`,Generator.ORDER_UNARY_POSTFIX]);
   
   }

    //% block="Read VEML6075 Radiation Emitted Mw/cm2" blockType="reporter"  
    export function DFRobot_VEML6075ReadyME(parameter: any, block: any) { 

        Generator.addCode( [`Uvi2mwpcm2(VEML6075.getUvi(VEML6075.getUva(),VEML6075.getUvb()))`,Generator.ORDER_UNARY_POSTFIX]);
   
   }
   
    function replace(str :string) {
        return str.replace("\"", "").replace("\"", "");
    }
   
}